<include file="Public:header" />
<div class="container main"> <include file="Public:left" />
  <div class="w790"> 
    <script>
  	function uploaded(path){
		$("#img_url").attr("src",'__PUBLIC__'+path);
		$("input[name='img_url']").val(path);
	}
	function del_img(){
		if(confirm('您确定要删除图片吗?')){
			var file=$("input[name='img_url']").val();
			$.post("{:U('delImgBypath')}",{'path':file},function(data){
				$("input[name='img_url']").val('');
				$("#img_url").attr('src','');
			});
		}else{
			return false;
		}
	}
	//切换栏目方式
	function parseCateType(e){
		if($(e).val()==1){
			$('#pagesize').show();
		}else{
			$('#pagesize').hide();
		}
	}
	function after(e){
	    $(e).parent().parent().parent().parent().parent('li').after($(e).parent().parent().parent().parent().parent('li').prev());
    }
    function append(e){
	    $(e).parent().parent().parent().parent().parent('li').next().after($(e).parent().parent().parent().parent().parent('li'));
    }
	function delnews(e){
		$(e).parent().parent().parent().parent().parent().remove();
	}
	function addnews(){
		var html = $('#copyHTML').html();
		$(html).appendTo('#replyList ul');
	}
	
	
	function getExtends(e){
		var v = $('#extendsList'+$(e).val()).val();
		$('#extends').val(v);
	}
  </script>
    <style>
  	#replyList ul li{margin-top:5px; background:#eee; padding:8px; width:700px;}
	.delnews{display:block; width:30px; font-size:20px; height:30px; border-radius:15px; background:#f00; color:#fff; line-height:30px; text-align:center;}
  </style>
    <div class="h"><a href="{:U('index')}" class="btn btn-info"><i class="glyphicon glyphicon-circle-arrow-left"></i> 返回采集</a> </div>
    <form class="checkoutform form-horizontal" action="{:U('update')}" method="post">
      <div class="table_ container">
        <input type="hidden" name="id" value="{$info.id}">
        <div class="form-group">
          <label class="col-sm-2 control-label">文章标题</label>
          <div class="col-sm-10">
            <input class="form-control" datatype="*" value="{$info.title}" name="title" type="text" placeholder="栏目名称">
          </div>
        </div>
        
        
        
        
         
      <div class="form-group">
      <label class="col-sm-2 control-label">所属分类</label>
      <div class="col-sm-10">
         <select class="form-control" datatype="*" name="collectcategory_id" id="collectcategory_id">
          <volist name="cate_list" id="vo">
            <option <eq name="vo['id']" value="$info['collectcategory_id']">selected="selected"</eq> value="{$vo.id}">{:getdeepstr($vo['deep'])}{$vo.title}</option>
             
          </volist>
        </select>
      </div>
   </div>
        
        
        
        
        
        
   
        <div class="form-group">
          <label class="col-sm-2 control-label">分享图片</label>
          <div class="col-sm-10">
            <input name="img_url" type="hidden" value="{$info.img_url}" />
            <img onclick="showImgBox(this);" src="<notempty name="info['img_url']">{:getThumbPath($info['img_url'])}
            <else/>
            __PUBLIC__/Admin/images/defaultimg.png
            </notempty>
            " id="img_url" height="40" /> </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">文章内容</label>
          <div class="col-sm-10">
            <html:editor id="editor" name="content" type="UEDIT" style="height:400px; width:100%;">{$info.content}</html:editor>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">分享标题</label>
          <div class="col-sm-10">
            <input class="form-control" name="page_title" type="text" id="page_title" size="50" />
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">分享描述</label>
          <div class="col-sm-10">
            <textarea class="form-control" name="description" class="" cols="50" rows="6" id="description">{$info.description}</textarea>
          </div>
        </div>
      </div>
      <div class="pages">
        <button type="submit" class="btn btn-success">发布</button>
      </div>
    </form>
  </div>
  <div class="clear"></div>
</div>
<script>
//加载广告位，实现编辑
function loadModules(id){
	$.post('<?php echo U('Modules/getOne');?>',
			{id:id}, function(data){
				if(data.data != ''){
					$('#AdvBox').html(data.data);
					bindEditText();
					$('#EditTextBox').mouseleave(function(e) {
            $(this).hide();
        });
				}
			},'json');
    
}

$(document).ready(function(e) {
	loadModules($('#modules_id').val());
});

    function showAdvList(id){
		mydialog.open('{:U('Home/Modules/AdvList', array('id' => 'pages_id'), true, false, true, __SITEID__)}'.replace('pages_id',id),{width: 1000, height: 700,lock:true,title:'请选择一个广告然后点击确定', ok:function(){
			var d = this.iframe.contentWindow.document;
			var modules_id = $(d).find('.on.viewBox').attr('modulesID');
			$('#modules_id').val(modules_id);
			loadModules(modules_id);
		}});
	}
	
	
	
	
	
	
	
	
	
	function bindEditText(){
		$('.viewBox').each(function(viewBoxindex, viewBoxelement) {
		$(viewBoxelement).find('.editText').each(function(index, element) {
			$(this).mouseenter(function(e) {
				var height = $(this).outerHeight();
				var width = $(this).outerWidth();
				var top = $(this).offset().top;
				var left = $(this).offset().left;
				$('#EditTextBox').css({'top':top+'px', 'left':left+'px', 'line-height':height+'px'});
				$('#EditTextBox').width(width-2);
				$('#EditTextBox').height(height-2);
				$('#EditTextBox').show();
				//var className = '.'+$(this).attr('class').replaceAll(' ','.');
				$('#EditTextBox').attr('name', $(this).attr('name'));
				$('#EditTextBox').attr('title', $(viewBoxelement).attr('title'));
				$('#EditTextBox').attr('modulesID', $(viewBoxelement).attr('modulesID'));
				$('#EditTextBox').attr('datatype', $(this).attr('datatype'));
				
				$('#EditTextBox').show();
			});
		});
	});
	}
	
	//编辑单个自定义字段
	function showEditTextBox(){
        $('#EditTextBox').hide();
		$('.viewBox *').unbind('mouseenter');
		var width = $(window).width();
		if(width > 400){
		    width = 400;
		}
		mydialog.open('<?php echo U('Admin/Modules/editText');?>'.replace('/<?php echo __SITEID__;?>/','/')+'?datatype='+$('#EditTextBox').attr('datatype')+'&name='+$('#EditTextBox').attr('name')+'&modules_id='+$('#EditTextBox').attr('modulesID'), {width: width+'px', height: 'auto',title:$('#EditTextBox').attr('title')+'-编辑',lock: false,ok:function(){
			var d = this.iframe.contentWindow.document;
			var textValue = $(d).find('#textValue').val();
			$.post(
			'<?php echo U('Admin/Modules/saveText');?>'.replace('/<?php echo __SITEID__;?>/','/'),
			{'name':$(d).find('#name').val(),'value':$(d).find('#value').val(), 'id':$(d).find('#id').val(), 'link':$(d).find('#link').val()},
			function(data){
				loadModules($('#EditTextBox').attr('modulesID'));
				
			},'json');
		}});
	}
	
	
	
	
	
	
	
	
	
	
	
	

		
</script>
<style>
    #AdvBox{border:1px dashed #CF9394;}
</style>
<!-- 查找元素时用的高亮层 -->
<div id="EditTextBox" datatype="" name="" modulesID="" onclick="showEditTextBox();" style="position: absolute; display:none; z-index: 8000000; background-color: rgba(0, 0, 0, 0.6); border:1px dashed #ccc; color:#fff; text-align:center; line-height:1;">点击修改</div>
<!-- 查找元素时用的高亮层end -->
</body></html>